public class Person {
    public String name;
    public char gender;
    public int age;
    public boolean married;

    public void marry(Person another) {
        // 在这里填空，判断自己 ( this ) 跟 另外一个人( another )结婚
        if ((this.gender == '男' && another.gender == '女') || (this.gender == '女' && another.gender == '男')) {
            if ((this.age >= 22 && another.age >= 20) || (this.age >= 20 && another.age >= 22)) {
                if (this.married == false && another.married == false) {
                    System.out.println(this.name + "," + another.name + "  满足条件这两个人可以结婚");
                } else {
                    System.out.println(this.name + "," + another.name + "  有一方已经结过婚,所以无法结婚");
                }

            } else {
                System.out.println(this.name + "," + another.name + "  有一方年龄不满足条件,无法结婚");
            }

        } else {
            System.out.println(this.name + "," + another.name + "  两人性别相同，无法结婚");
        }
    }

    public static void main(String[] args) {
        Person first = new Person();
        first.name = "小明";
        first.gender = '男';
        first.age = 23;
        first.married = false;

        Person second = new Person();
        second.name = "小红";
        second.gender = '女';
        second.age = 20;
        second.married = false;

        Person third = new Person();
        third.name = "小刚";
        third.gender = '男';
        third.age = 16;
        third.married = false;

        Person fourth = new Person();
        fourth.name = "小花";
        fourth.gender = '女';
        fourth.age = 30;
        fourth.married = true;

        second.marry(first);// 小红,小明 满足条件这两个人可以结婚

        third.marry(first);// 小刚,小明 两人性别相同，无法结婚

        third.marry(second);// 小刚,小红 有一方年龄不满足条件,无法结婚

        fourth.marry(first);// 小花,小明 有一方已经结过婚,所以无法结婚

    }
}